<#include "${ftl_skin}/common/header.ftl">


</head>
<body class="white-bg">
<div class="animated fadeInRight">
    <div class="ibox float-e-margins row">
       <!-- <div class="ibox-title"></div>-->
        <div class="ibox-content p-t0">
        	<h4>用户管理 (部门 : ${(deptVO.dept_name)!})</h4>
            <!--搜索栏-->
            <form id="bs-form" role="form" class="form-horizontal">
              <div class="ibox-form">
              	<div class="form-box clearfix">
                	<label for="tag_title" class="col-sm-1 col-hf-10 control-label">用户姓名 : </label>
                    <div class="col-sm-2 col-hf-15">
                        <input type="text" placeholder="请输入用户姓名" name="user_name" id="user_name" class="form-control">
                    </div>
                    <label for="tag_title" class="col-sm-1 col-hf-10 control-label">用户账号 : </label>
                    <div class="col-sm-2 col-hf-15">
                        <input type="text" placeholder="请输入用户账号" name="user_code" id="user_code" class="form-control">
                    </div>
                    <!--查询按钮-->
                    <div class="ibox-right col-hf-9">
                    	<button class="btn btn-primary" type="button" onClick="searchBSTable('bs-table', 'bs-form');return false;">搜索</button>
                    </div>
                    <!--查询按钮-->
                </div>
              </div>
            </form>
            <!--/搜索栏-->

            <!--列表-->

            <!--工具栏-->
            <div id="bs-toolbar" class="btn-group">
                <button type="button" class="btn  btn-primary btn-sm" onClick="item_add();return false;">
                    添加
                </button>

                <!--
                <button type="button" class="btn btn-outline btn-default">
                    <i class="glyphicon glyphicon-heart" aria-hidden="true"></i>
                </button>
                -->
               <button type="button" class="btn  btn-warning btn-sm" onClick="item_del(getUserCode('bs-table'));return false;">
                    删除
                </button>

            </div>
            <!--/工具栏-->

            <table 	id="bs-table"
                      data-url="${path.servicePath}user/userlist.do?dept_id=${(deptVO.tree_id)!}"
                      data-method="post"
                      data-response-handler="pagerTableResponseHandler"
                      data-pagination="true"
                      data-page-list="[10, 20, 50, 100]"

                      data-toolbar="#bs-toolbar"
                      data-resizable="false"

                      data-side-pagination="server"
                      data-content-type="application/x-www-form-urlencoded;charset=utf-8"

                      data-click-to-select="true"
                      data-single-select="false"

                      data-query-params="setParams"
                      
                      data-classes="table table-hover table-condensed"
                      data-striped="true"
                      >
                <thead>
                <tr>
                    
                    <th data-field="tableid" data-checkbox="true"></th>
                    <th data-field="user_name" data-align="center" data-sortable="true">用户名称</th>
                    <th data-field="user_code" data-align="center" data-sortable="true">用户帐号</th>
                    <th data-field="mobile_phone" data-align="center" data-sortable="true">联系电话</th>
                    <th data-field="e_mail_addr" data-align="center" data-sortable="true" data-width="90">电子邮箱</th>
                    <th data-formatter="operateFormatter" data-width="190" data-align="center">操作</th>

                </tr>
                </thead>
            </table>

            <!--/列表-->



        </div><!-- end ibox-content -->
    </div><!-- end ibox -->
</div><!-- end wrap -->



<#include "${ftl_skin}/common/js.ftl">


<script type="text/javascript">
    $(function(){

        initBSTable('bs-table', {});

        // openDialog('item_edit', '客户信息', 'http://www.hong-feng.com', '', 650, 300, dialogCallback);


        // HFToastr("标题", "哈哈");
        // HFConfirm("哈哈", "", "", function(isConfirm){
        // 	HFAlert('adf' + isConfirm);
        // });
    });

    //格式化显示
    function operateFormatter(value, row, index) {
        return [
            '<button onclick="javascript:item_config(\'' + row.user_code + '\');" type="button" class="btn  btn-primary btn-sm">',
            '权限配置',
            '</button>&nbsp;',
            '<button onclick="javascript:item_edit(\'' + row.user_code + '\');" type="button" class="btn  btn-primary btn-sm">',
            '编辑',
            '</button>&nbsp;',
            '<button onclick="javascript:item_del(\'' + row.user_code + '\');" type="button" class="btn  btn-warning btn-sm">',
            '删除',
            '</button>'
        ].join('');
    }

    function item_add(){

        openDialog('item_edit', '用户信息', '${path.viewPath }user/useredit.do?dept_id=${(deptVO.tree_id)!}', '', 650, 550, function(){
            var returnVal = this.returnValue;
            if(returnVal == 'reload'){
                refreshBSTable('bs-table');
            }
            return false;
        });

        // alert('新增');
    }
    function item_del(itemid){

        // var ids = getIdSelections('bs-table');
        // if(ids == ''){
        // 	HFAlert("请先选择需要操作的数据！", "", "warning");
        // 	return;
        // }

        HFConfirm("确认要删除选中该信息吗？", "", "warning", function(isConfirm){
            if(isConfirm){
                HFAjax("${path.servicePath }user/userdel.do", {itemid: itemid}, function(result){
                    HFToastrTipResult(result);
                    refreshBSTable('bs-table');
                });
            }
        });

        // alert('删除' + itemid);
    }
    function item_edit(itemid){

        openDialog('item_edit', '用户信息', '${path.viewPath }user/useredit.do?itemid=' + itemid, '', 650, 550, function(){
            var returnVal = this.returnValue;
            if(returnVal == 'reload'){
                refreshBSTable('bs-table');
            }
            return false;
        });

        // alert('编辑' + itemid);
    }

    function item_config(itemid){

        openDialog('item_config', '用户权限', '${path.viewPath }auth/cfg.do?type=${Status.OBJ_TYPE_USER.val() }&id=' + itemid, '', 800, 550, function(){
            var returnVal = this.returnValue;
            if(returnVal == 'reload'){
                refreshBSTable('bs-table');
            }
            return false;
        });
    }

    function getUserCode(tableid) {
        var arr = $.map($('#' + tableid).bootstrapTable('getSelections'), function (row) {
            if (row.user_code) {
                return row.user_code
            }else{
                return "";
            }
        });

        var str = '';
        for(var i in arr) {
            if(i == 0){
                str += arr[i];
            }else {
                str += ',' + arr[i];
            }
        }
        return str;
    }

</script>

<#include "${ftl_skin}/common/footer.ftl">